home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / MacInterface / dialogs.icl < prev    next >
Encoding:
Modula Implementation  |  1996-02-22  |  7.1 KB  |  194 lines  |  [TEXT/3PRM]

  1. implementation module dialogs;
  2.  
  3. import mac_types;
  4.  
  5. ::    ProcPtr :== Int;
  6.  
  7. //    Initialization
  8.  
  9. InitDialogs :: !ProcPtr !Toolbox -> Toolbox;
  10. InitDialogs resumeProc t = code (resumeProc=L,t=U)(z=Z){
  11.     instruction 0xA97B
  12. };
  13.  
  14. //    Creating and Disposing of Dialogs
  15.  
  16. NewDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr, !Toolbox);
  17. NewDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t 
  18. = code (right=W,bottom=W,left=W,top=W,dStorage=R4L,title=O8S,visible=W,procID=W, 
  19.     behind=L,goAwayFlag=W,refCon=L,items=L,t=U) (dialog=L,z=I8Z)
  20. {
  21.     instruction 0xA97D            ||    _NewDialog
  22. };
  23.  
  24. NewCDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr,!Toolbox);
  25. NewCDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t
  26. = code (right=W,bottom=W,left=W,top=W,dStorage=R4L,title=O8S,visible=W,procID=W,
  27.     behind=L,goAwayFlag=W,refCon=L,items=L,t=U) (dialog=L,z=I8Z)
  28. {
  29.     instruction 0xAA4B            ||    _NewCDialog
  30. };
  31.  
  32. CloseDialog :: !DialogPtr !Toolbox -> Toolbox;
  33. CloseDialog theDialog t = code (theDialog=L,t=U)(z=Z){
  34.     instruction 0xA97D    ||    _CloseDialog
  35. };
  36.  
  37. DisposDialog :: !DialogPtr !Toolbox -> Toolbox;
  38. DisposDialog theDialog t = code (theDialog=L,t=U)(z=Z){
  39.     instruction 0xA983
  40. };
  41.  
  42. //    Handling Dialog Events
  43.  
  44. ModalDialog :: !ProcPtr !DialogPtr !Toolbox -> (!Int,!Toolbox);
  45. ModalDialog filterProc dialog t = code (filterProc=R2L,dialog=O4U,t=U)(itemHit=W,z=Z){
  46.     instruction 0xA991            ||    _ModalDialog
  47. };
  48.  
  49. IsDialogEvent :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!Toolbox);
  50. IsDialogEvent event tb = IsDialogEvent1 event;
  51.  
  52. IsDialogEvent1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!Toolbox);
  53. IsDialogEvent1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D1,z=I16Z){
  54.     instruction 0x558F            ||    subq.l    #2,sp
  55.     instruction 0x486F 0x0002    ||    pea     2(sp)
  56.     instruction 0xA97F
  57.     instruction 0x7001            ||    moveq    #1,d0
  58.     instruction 0xC01F            ||    and.b    (sp)+,d0
  59.     instruction 0x4480            ||    neg.l    d0
  60.     instruction 0x2200            ||    move.l    d0,d1
  61. };
  62.  
  63. DialogSelect :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!DialogPtr,!Int,!Toolbox);
  64. DialogSelect event tb
  65. =    (b, dPtr, itemNr, tb);
  66.     where{
  67.         (b, dPtr, itemNr) = DialogSelect1 event};
  68.  
  69. DialogSelect1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!DialogPtr,!Int);
  70. DialogSelect1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D2,theDialog=D1,itemHit=D0){
  71.     instruction 0x518F            ||    subq.l    #8,sp
  72.     instruction 0x486F 0x0008    ||    pea     8(sp)
  73.     instruction 0x486F 0x0006    ||    pea     6(sp)
  74.     instruction 0x486F 0x000E    ||    pea     14(sp)
  75.     instruction 0xA980
  76.     instruction 0x7401            ||    moveq    #1,d2
  77.     instruction 0xC41F            ||    and.b    (sp)+,d2
  78.     instruction 0x4482            ||    neg.l    d2
  79.     instruction 0x221F            ||    move.l    (sp)+,d1
  80.     instruction 0x301F            ||    move    (sp)+,d0
  81.     instruction 0x48C0            ||    ext.l    d0
  82.     instruction 0x4FEF 0x0010    ||    lea        16(sp),sp        
  83. };
  84.  
  85. //    Invoking Alerts
  86.  
  87. //    Manipulating Items in Dialogs and Alerts
  88.  
  89. GetDItem :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Rect,!Toolbox);
  90. GetDItem theDialog itemNo tb
  91. =    (itemType, item, rect, NewToolbox);
  92.     where{
  93.         (itemType, item, rect) = GetDItem1 theDialog itemNo tb};
  94.  
  95. GetDItem1 :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Rect);
  96. GetDItem1 theDialog itemNo t = code (theDialog=R14L,itemNo=W,t=U)(itemType=D5,item=D4,left=D3,top=D2,right=D1,bottom=D0){
  97.     instruction 0x486F 0x0006    ||    pea        6(sp)
  98.     instruction 0x486F 0x000C    ||    pea     12(sp)
  99.     instruction 0x486F 0x0014    ||    pea     20(sp)
  100.     instruction 0xA98D            ||    _GetDItem
  101.     instruction 0x3A1F            ||    move    (sp)+,d5
  102.     instruction 0x48C5            ||    ext.l    d5
  103.     instruction 0x281F            ||    move.l    (sp)+,d4
  104.     instruction 0x4C9F 0x000F    ||    movem    (sp)+,d0-d3
  105.     instruction 0xC340            ||    exg d1,d0
  106.     instruction 0xC742            ||    exg d3,d2
  107. };
  108.  
  109. SetIText :: !Handle !{#Char} !Toolbox -> Toolbox;
  110. SetIText item text t = code (item=L,text=S,t=U)(z=Z){
  111.     instruction 0xA98F
  112. };
  113.  
  114. GetIText :: !Handle !{#Char} !Toolbox -> (!{#Char},!Toolbox);
  115. GetIText item text tb = (GetIText1 item text tb, NewToolbox);
  116.  
  117. GetIText1 :: !Handle !{#Char} !Toolbox -> {#Char};
  118. GetIText1 item text t = code (item=L,text=A0,t=U)(new_text=A0){
  119.     instruction 0x2808            ||    move.l    a0,d4
  120.     instruction 0x42A8 0x0004    ||    clr.l    4(a0)
  121.     instruction 0x4868 0x0007    ||    pea     7(a0)
  122.     instruction 0xA990            ||    _GetIText
  123.     instruction 0x2044            ||    move.l    d4,a0
  124. };
  125.  
  126. SelIText :: !DialogPtr !Int !Int !Int !Toolbox -> Toolbox;
  127. SelIText theDialog itemNo strtSel endSel t = code (theDialog=L,itemNo=W,strtSel=W,endSel=W,t=U)(z=Z){
  128.     instruction 0xA97E    ||    _SelIText
  129. };
  130.  
  131. OutlineButtonFunction :: ProcPtr;
  132. OutlineButtonFunction = code ()(function_address=D0){
  133.     instruction    0x41FA 0x0006            |        lea        l1(pc),a0
  134.     instruction    0x2008                    |        move.l    a0,d0
  135.     instruction 0x6040                    |        bra.s    l2
  136.     instruction    0x201F                    |    l1:    move.l    (sp)+,d0
  137.     instruction    0x321F                    |        move.w    (sp)+,d1
  138.     instruction    0x241F                    |        move.l    (sp)+,d2
  139.     instruction    0x2F00                    |        move.l    d0,-(sp)
  140.     instruction    0x4FEF 0xFFF2            |        lea        -14(sp),sp
  141.     instruction    0x2F02                    |        move.l    d2,-(sp)
  142.     instruction    0x3F01                    |        move.w    d1,-(sp)
  143.     instruction    0x486F 0x0006            |        pea        6(sp)
  144.     instruction    0x486F 0x000C            |        pea        12(sp)
  145.     instruction    0x486F 0x0014            |        pea        20(sp)
  146.     instruction    0xA98D                    |        _GetDItem
  147.     instruction    0x5C8F                    |        addq.l    #6,sp
  148.     instruction    0x2F3C 0x0003 0x0003    |        move.l    #$00030003,-(sp)
  149.     instruction    0xA89B                    |        _PenSize
  150.     instruction 0x2F0F                    |        move.l    sp,-(sp)
  151.     instruction    0x2F3C 0xFFFC 0xFFFC    |        move.l    #$fffcfffc,-(sp)
  152.     instruction    0xA8A9                    |        _InsetRect
  153.     instruction 0x2F0F                    |        move.l    sp,-(sp)
  154.     instruction    0x2F3C 0x0010 0x0010    |        move.l    #$00100010,-(sp)
  155.     instruction    0xA8B0                    |        _FrameRoundRect
  156.     instruction    0x508F                    |        addq.l    #8,sp
  157.     instruction    0x4E75                    |        rts
  158.                                         |    l2:
  159. };
  160.  
  161. DisposeRoutineDescriptor :: !ProcPtr !Toolbox -> Toolbox;
  162. DisposeRoutineDescriptor p t = t;
  163.  
  164. DialogFilterFunction :: ProcPtr;
  165. DialogFilterFunction = code ()(function_address=D0){
  166.     instruction 0x41FA 0x0006            |                lea    l2(pc),a0
  167.     instruction 0x2008                    |               move.l    a0,d0
  168.     instruction 0x6046                    |                bra.s    l3:
  169.     instruction 0x2017                    |   l2:            move.l    (sp),d0
  170.     instruction 0x508F                    |               addq.l    #8,sp
  171.     instruction 0x205F                    |               move.l    (sp)+,a0
  172.     instruction 0x2257                    |               move.l    (sp),a1
  173.     instruction 0x2E80                    |               move.l    d0,(sp)
  174.     instruction 0x0C50 0x0006            |                 cmp.w    #6,(a0)
  175.     instruction 0x670E                    |                beq.s    update
  176.     instruction 0x0C50 0x0003            |                  cmp.w    #3,(a0)
  177.     instruction 0x6714                    |                beq.s    key_down
  178.     instruction 0x4251                    |   ret_false:    clr.w    (a1)
  179.     instruction 0x426F 0x0004            |                  clr.w    4(sp)
  180.     instruction 0x4E75                    |                rts
  181.     instruction 0x32BC 0xFFFF            |      update:        move.w    #-1,(a1)
  182.     instruction 0x3F7C 0xFFFF 0x0004    |                move.w    #-1,4(sp)
  183.     instruction 0x4E75                    |                 rts
  184.     instruction 0x1028 0x0005              |    key_down:    move.b    5(a0),d0
  185.     instruction 0x0C00 0x000D           |                  cmp.b    #13,d0
  186.     instruction 0x6706                     |                beq.s    return_key
  187.     instruction 0x0C00 0x0003           |                  cmp.b    #3,d0
  188.     instruction 0x66DC                     |                 bne.s    ret_false
  189.     instruction 0x32BC 0x0001           |    return_key:    move.w    #1,(a1)
  190.     instruction 0x3F7C 0xFFFF 0x0004    |                move.w    #-1,4(sp)
  191.     instruction 0x4E75                  |                 rts
  192.                                         | l3:
  193. };
  194.